home *** CD-ROM | disk | FTP | other *** search
- Path: iafrica.com!usenet
- From: Peter Golda <goldap@telkom11.telkom.co.za>
- Newsgroups: comp.lang.c++
- Subject: Default values for constructor arguments
- Date: 6 Mar 1996 10:17:51 GMT
- Organization: Telkom
- Message-ID: <4hjoof$5qk@newnews.iafrica.com>
- NNTP-Posting-Host: wfor-koeppenp.telkom.co.za
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.1N (Windows; I; 16bit)
-
- Hi,
-
- I had a constructor for my MWMessageLog class as follows:
-
- MWMessageLog(
- const RWCString& anExecutableCode,
- const RWCString& aSystemCode,
- const RWCString& aLogFilePath );
-
- where the class RWCString comes from the Rogue Wave development library
- and is just a simple string class.
-
- Now, I wanted to add default values, so I wrote as follows (knowing that
- RWCString has a constructor that constructs RWCString from char* and it
- has an assignment operator):
-
- MWMessageLog(
- ...
- ...
- const RWCString& aLogFilePath = "~/logs/" );
-
- but now the compiler moans that it doesn't like that since the default
- value must be passed through a constructor.
-
- So, I thought I'd create a static member variable in my class of
- type RWCstring; initialise it to "~/logs/" and then use the variable's
- name as my default value in the constructor. But that fails too.
-
- The C++ ARM has an example of something similar on page 143 (Ch8, Default
- Arguments) - but it doesn't seem to work...
-
- My question thus is:
-
- Can I use default values with classes/types that are not inbuilt, but
- may be constructed of one inbuilt type value. If so, how can I do it
- without making a big mess of things ?
-
- Thanks,
- Pete.
-
-
-